<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('生字管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>字：</p>
                                <input type="text" name="zi"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="dict:zi:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="dict:zi:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="dict:zi:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dict:zi:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dict:zi:remove')}]];
        var jiegouDatas = [[${@dict.getType('zi_jiegou')}]];
        var prefix = ctx + "dict/zi";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "生字管理",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'zi', 
                    title : '字'
                },
                {
                    field : 'jtz', 
                    title : '简体字'
                },
                {
                    field : 'fzi', 
                    title : '繁体字'
                },
                {
                    field : 'py', 
                    title : '拼音'
                },
                {
                    field : 'zipin', 
                    title : '字频'
                },
                {
                    field : 'pinyin', 
                    title : '拼音'
                },
                {
                    field : 'wubi', 
                    title : '五笔'
                },
                {
                    field : 'wubi86',
                    title : '五笔(86)'
                },
                {
                    field : 'wubi98',
                    title : '五笔(98)'
                },
                {
                    field : 'bushou', 
                    title : '部首'
                },
                {
                    field : 'jiegou', 
                    title : '结构',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(jiegouDatas, value);
                    }
                },
                {
                    field : 'zongbihua', 
                    title : '总笔划'
                },
                {
                    field : 'buwaibihua', 
                    title : '部外笔划'
                },
                {
                    field : 'cangjie', 
                    title : '仓颉'
                },
                {
                    field : 'zhengma', 
                    title : '郑码'
                },
                {
                    field : 'sijiao', 
                    title : '四角'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editXiangjieJson(\'' + row.id + '\')"><i class="fa fa-edit"></i>详解Json</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editGuhanyuJson(\'' + row.id + '\')"><i class="fa fa-edit"></i>古汉语Json</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editKkcJson(\'' + row.id + '\')"><i class="fa fa-edit"></i>快快查解释Json</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="compare(\'' + row.id + '\')"><i class="fa fa-edit"></i>数据对比</a> ');
                        if(row.xiangjieAiJson){
                           actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="aiCompare(\'' + row.id + '\')"><i class="fa fa-edit"></i>快快查解释</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function editXiangjieJson(ziId) {
		    var url = prefix + "/xiangjieJsonEdit/" + ziId;
		    $.modal.openFull("详解Json编辑", url);
		}

		function editGuhanyuJson(ziId) {
		    var url = prefix + "/guhanyuJsonEdit/" + ziId;
		    $.modal.openFull("古汉语Json编辑", url);
		}

		function editKkcJson(ziId) {
		    var url = prefix + "/kkcJsonEdit/" + ziId;
		    $.modal.openFull("快快查解释Json编辑", url);
		}

		function compare(ziId) {
		    var url = prefix + "/compare/" + ziId;
		    $.modal.openFull("数据对比", url);
		}

        function aiCompare(ziId) {
		    var url = prefix + "/aiCompare/" + ziId;
		    $.modal.openFull("快快查解释", url);
		}


    </script>
</body>
</html>